package gorm

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"server/chat_room_server/internal/config"
)

func NewMysqlDB(c config.Config) (db *gorm.DB, err error) {
	fmt.Println(c.DB.Mysql.Dsn, "======")
	db, err = gorm.Open(mysql.Open(c.DB.Mysql.Dsn), &gorm.Config{})
	if err != nil {
		panic("failed to connect database")
	}
	initDB(db)
	return db, nil
}
